<div class='page_head'>
<h2><%="All messages".t%> </h2>
</div>

<%if @messages.size == 0%>

 <div class=tour>
   <h2><%=link_to "Post the first message for this project".t,new_message_url(params[:project_id])%></h2>
   <%="Post messages, share project updates, ask questions, communicate.".t%>
 </div>
 <%=feature'message'%>
 <%=feature'new_message'%>

<%else%>

<% for message in @messages %>
  
  <%if flash[:notice] == message.id %>
   <div class="message" id=fade> 
     <script> waittofade(); </script>
  <%else%>
   <div class="message">
  <%end%>
    <span class="private_label float_right"><%="Private".t if message.private%></span>
    <h1 class="msg_name">
       <%=image_tag"paperclip.gif" if message.files.size > 0 %>
        <%=link_to message.name,message_url(message.project,message)%> 
    </h1>
    <div class="msg_body">
      <%=CGI.unescapeHTML(message.body.to_s)%>
    </div>
    <div class='msg_prop'>
     <%="by".t%> <%=message.user.name%>
     <%="in".t + " " + link_to(message.category.name,project_msg_in_category_url(@project.id,message.category.id)) if message.category%>
     <%="on".t + " " +  message.created_at.strftime('%Y-%m-%d %H:%M')%> 
     <%="|" + link_to("Edit".t,edit_message_path(message.project.id,message),:class=>'admin') if @cur_user.id == message.user.id %> 
     | <%=link_to (message.comments.size == 0 ? "Post the first comment".t : message.comments.size.to_s + " comments".t),message_path(message.project.id,message) + "#comment"%>

    </div>
   </div>
<% end %>

<div class="float_right page">
  <%if @message_pages.length > 1%>
   Pages:
  <%end%>
  <% if params[:category_id] %>
   <%=pagination_links @message_pages,:params=>{:controller=>'redirect',:url=> project_msg_in_category_url(params[:project_id],params[:category_id])}%>
  <%else%>
    <%= link_to '<<', messages_path(params[:project_id]) + "?page=" + @message_pages.current.previous.to_i.to_s if @message_pages.current.previous %>
   <%=pagination_links @message_pages%>
    <%= link_to '>>', messages_path(params[:project_id]) + "?page=" + @message_pages.current.next.to_i.to_s if @message_pages.current.next%>
  <%end%>
</div>
<%end%>
